#include "linked_list.h"

int main(){
	List l;
	l.insertAtHead(1);
	l.insertAtHead(2);
	l.insertAtHead(3);
	l.insertAtHead(4);
	
	List l2;
	l2.insertAtTail(1);
	l2.insertAtTail(2);
	l2.insertAtTail(3);
	l2.insertAtTail(4);
	
	l.printList();
	l2.printList();
	
	l.printResult(2);
	l2.printResult(5);
	
	l.deleteNode(1);
	l.printList();
	
	
	l2.reverse();
	l2.printList();
	
	l2.iterateReverseList();
	l2.printList();
	
	std::cout<<l2.getLength()<<std::endl;
	
	List l3;
	l3.insertAtTail(1);
	l3.insertAtTail(3);
	l3.insertAtTail(5);
	l3.insertAtTail(7);
	
	NodePtr middle = l3.findMiddleNode();
	std::cout<<"中间节点为：";
	std::cout<<middle->val<<std::endl;
	
	List l4;
	l4.insertAtTail(2);
	l4.insertAtTail(4);
	l4.insertAtTail(6);
	l4.insertAtTail(8);
	l4.insertAtTail(10);
	
	NodePtr merged = l3.mergeSortedLists(l3.getHead(), l4.getHead());
	merged->printList();
	
	
	NodePtr last = l4.getHead();
	if (last) {
		while (last->next) {
			last = last->next;
		}
		last->next = l4.getHead();
	}
	
	
	
	std::cout<<l4.hasCycle()<<std::endl;
}


